﻿using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace YArchitech.HYSpace
{
	internal class Editor : UITypeEditor
	{
		public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
		{
			return UITypeEditorEditStyle.Modal;
		}

		public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
		{
			bool flag = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)) != null;
			string description = context.PropertyDescriptor.Description;
			string text = value.ToString();
			LoadParamOperate loadParamOperate = new LoadParamOperate();
			string text2 = description.Replace("盈建科-", "");
			string text3 = text2.Replace("时间表", "");
			if (!loadParamOperate.IsEffectiveTimeAssignName(text3, text, loadParamOperate.GetAllTimeInfo()))
			{
				text = text2.Replace("时间表", "_默认");
			}
			if (flag)
			{
				FrmTimeAssignManage frmTimeAssignManage = new FrmTimeAssignManage(text3, text);
				if (frmTimeAssignManage.ShowDialog().Equals(DialogResult.OK))
				{
					if (value.ToString() != frmTimeAssignManage.selectedNodeText)
					{
						return frmTimeAssignManage.selectedNodeText;
					}
				}
				else if (!loadParamOperate.IsEffectiveTimeAssignName(text3, text, FrmTimeAssignManage.listTimeAssign))
				{
					return text2.Replace("时间表", "_默认");
				}
			}
			return value;
		}

		public override bool GetPaintValueSupported(ITypeDescriptorContext context)
		{
			return false;
		}
	}
}
